package com.ruoyi.system.enums;

/**
 * 操作类型枚举
 */
public enum OperationType {
    /**
     * 入库
     */
    INBOUND("1", "入库"),

    /**
     * 出库
     */
    OUTBOUND("2", "出库"),

    /**
     * 移库
     */
    TRANSFER("3", "移库"),

    /**
     * 盘库
     */
    INVENTORY("4", "盘库");

    private final String code;
    private final String description;

    OperationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举
     */
    public static OperationType getByCode(String code) {
        for (OperationType value : values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据description获取枚举
     */
    public static OperationType getByDescription(String description) {
        for (OperationType value : values()) {
            if (value.description.equals(description)) {
                return value;
            }
        }
        return null;
    }
}
